package cn.virens.library.widget.form;


/**
 * Created by loioi on 2017/6/16.
 */

public class FormException extends Exception {
    private final Form form;
    private final String error;

    public FormException(Form form) {
        this(form, null);
    }

    public FormException(Form form, String error) {
        this.form = form;
        this.error = error;
    }

    public Form getForm() {
        return form;
    }

    public String getError() {
        return getMessage();
    }

    @Override
    public String getMessage() {
        if (error == null) {
            return super.getMessage();
        } else {
            return error;
        }
    }
}
